//给你单链表的头节点 head ，请你反转链表，并返回反转后的链表。
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */
//遍历循环原链表依次头插
typedef struct ListNode ListNode;
struct ListNode* reverseList(struct ListNode* head)
{
    ListNode* pcur = head;
    ListNode* newHead, *newTail;
    newHead = newTail = NULL;
    ListNode* temp = NULL;
    if(head == NULL)
    {
        return head;
    }
    while(pcur)
    {
        temp = pcur->next;
        //就执行头插的操作
        if(newHead == NULL)
        {
            newHead = newTail = pcur;
        }
        else
        {
            pcur->next = newHead;
            newHead = pcur;
        }
        pcur = temp;
    }
    newTail->next = NULL;
    return newHead;
}